#ifndef __SYSTEMS_H
#define __SYSTEMS_H

#include <stdio.h>
#include <string.h>

#include <config.h>
#include <types.h>

#ifdef DEBUG
#ifdef NON_OS
#define DPRINTF(str, args...)   printf(str, ##args)  /* debug output*/
#define DPRINTF2(str, args...)   printf("DEBUG(%s): " str, __func__, ##args)  /* debug output*/
#else
#define DPRINTF(str, args...)   fprintf(stderr, str, ##args)  /* debug output*/
#define DPRINTF2(str, args...)   fprintf(stderr, "DEBUG(%s): " str, __func__, ##args)  /* debug output*/
#endif
#else
#define DPRINTF(str, ...)	/* no debug output*/
#define DPRINTF2(str, ...)
#endif

#ifdef NON_OS
#define ERROR(str, args...) printf("ERROR: " str, ##args)
#define WARNING(str, args...) printf("WARNING: " str, ##args)
#else
#define ERROR(str, args...) fprintf(stderr, "ERROR: " str, ##args)
#define WARNING(str, args...) fprintf(stderr, "WARNING: " str, ##args)
#endif

#ifdef NIOS2_FPU_SUPPORT
# define CI_FPU_ADD 253
# define CI_FPU_SUB 254
# define CI_FPU_MUL 252
# define CI_FPU_DIV 255
# define FPU_ADD(a, b) __builtin_custom_fnff(CI_FPU_ADD, a, b)
# define FPU_SUB(a, b) __builtin_custom_fnff(CI_FPU_SUB, a, b)
# define FPU_MUL(a, b) __builtin_custom_fnff(CI_FPU_MUL, a, b)
# define FPU_DIV(a, b) __builtin_custom_fnff(CI_FPU_DIV, a, b)
#endif

#ifdef NIOS2_COLOR_TRANSFORM_SUPPORT
# define CT_YCbCr2RGB565(a) __builtin_custom_ini(0, a)
# define CT_RGB2RGB565(r, g, b) __builtin_custom_ini(1, r << 16 | g << 8 | b)
#endif


void fb_open(void);
void fb_close(void);
int graph_sys_init(void);
int graph_sys_exit(void);

#endif
